home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
178_01
/
tvx_lex.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-01-16
|
14KB
|
530 lines
/* -------------------------- tvx_lex.c ----------------------------------- */
#include "tvx_defs.ic"
/* -------------------------- GLOBALS GO HERE -------------------------------*/
#define EXTERN
#include "tvx_glbl.ic"
char clower(),cupper();
/* =============================>>> CHECKOS <<<============================= */
checkos()
{
/* check if ok operating system */
#ifdef MSDOS
if ((bdos(0x30,0) & 0xff) < 2) /* !!! cii-86 dependent */
{
remark("TVX requires MS-DOS 2.0 or later");
exit();
}
#endif
}
/* =============================>>> STARTM <<<============================= */
startm()
{
prompt("TVX - Full Screen Editor ");
prompt(VERSION); prompt("Terminal: ");
remark(cversn);
remark("");
remark("? for help");
remark("");
}
/* =============================>>> MEMORY <<<============================= */
memory()
{ /* memory - print memory left */
SLOW int nxt,chrsavail;
SLOW unsigned int tmp;
char value[10],msg[85],*cp,stemp[80];
nxt = 0; /* where message goes */
stcopy(" Chrs left:",0,stemp,&nxt); /* add ' Chars: ' */
#ifdef LASL
tmp = max(nxtsav - nxtchr - BUFFLIMIT,0);
#else
tmp = nxtsav - nxtchr;
#endif
#ifdef INT16
if (tmp > 30000) /* handle "neg" size */
{
stemp[nxt++] = '+';
tmp -= 30000;
}
#endif
itoa(tmp,value);
stcopy(value,0,stemp,&nxt); /* the value */
stcopy(" Last line:",0,stemp,&nxt); /* add ' Lines: ' */
itoa(nxtlin-1,value);
stcopy(value,0,stemp,&nxt); /* add the count */
#ifdef STATCURLINE
stcopy(" Cur line:",0,stemp,&nxt); /* add ' Cur line: ' */
itoa(curlin,value);
#endif
#ifdef STATREPEAT
stcopy(" Rpt:",0,stemp,&nxt); /* add ' Rpt: ' */
itoa(rptuse+1,value);
stcopy(value,0,stemp,&nxt); /* the count */
stcopy("/",0,stemp,&nxt); /* add '/' */
itoa(REPEATBUFS,value);
#endif
stcopy(value,0,stemp,&nxt);
chrsavail=80-strlen(stemp);
nxt=0; /* where message goes */
cp = (*dest_file ? dest_file : orig_file);
stcopy(cp,max(strlen(cp)-chrsavail,0),msg,&nxt); /* the file name */
if (strlen(VERSION) <= chrsavail-nxt)
{
stcopy(VERSION,0,msg,&nxt); /* TVX */
if (strlen(cversn) <= chrsavail-nxt)
stcopy(cversn,0,msg,&nxt); /* terminal type */
}
stcopy(stemp,0,msg,&nxt); /* rest of string */
tverr(msg); /* display line on screen */
}
/* =============================>>> SHOSET <<<============================= */
shoset()
{ /* show repeat buffer, help if available */
#ifdef HELP
static char rp[2];
FAST int i;
SLOW char *cp, *msg;
SLOW int fields, oldtty, hnum;
SLOW unsigned tmp;
#ifdef FULLHELP
struct help_msg
{
char *hmsg;
char Vmsg;
};
static struct help_msg cmddes[] = /* messages for help */
{
{"nApnd to sv buff", VSAPPEND},
{" Buffer beg ", VTOP},
{" File beg", VFBEGIN},
{"nChange chars ", VCHANGE},
{"nDown line ", VDOWNLINE},
{"nDown column", VDOWNCOL},
{" Buffer end ", VBOTTOM},
{"nEdit rpt buffer", VEDITRPT},
{"nFind", VSEARCH},
{" Find cross-buff", VNEXT},
{" Get save buffer", VGET},
{" Unkill lastline", VUNKILL},
{"nHalf page ", VHALFP},
{"nInsert (to ESC)", VINSERT},
{" Jump back", VJUMP},
{"nKill character ", VDELNEXT},
{"nKill line ", VKILLALL},
{"nLeft", VLEFT},
{" Memory status ", VMEMORY},
{"nNote location ", VNOTELOC},
{"nReset loc", VRETNOTE},
{"nOpen line ", VOPENLINE},
{" Call Opr system", VSYSTEM},
{"nPage", VFLIP},
{" Print screen ", VPRINTS},
{"nRight ", VRIGHT},
{" Restore rpt buf", VSTORERPT},
{"nSave lines ", VSAVE},
{"nTidy, fill text", VTIDY},
{" Abort", VABORT},
{"nUp ", VUPLINE},
{"nUp column ", VUPCOL},
{" Verify screen", VVERIFY},
{"nWrite buffer ", VWPAGE},
{" Exit, end edit ", VQUIT},
{"nYank file", VYANK},
{"nDel prev char ", VDELLAST},
{"nFind again ", VSAGAIN},
{" Del last", VREMOVE},
{" Change last ", VRMVINS},
{" Del to line beg", VKILLPREV},
{" Del to line end", VKILLREST},
{" Line begining ", VBEGLINE},
{" Line end ", VENDLINE},
{"nWord right", VMVWORD},
{"nWord left ", VMVBWORD},
{"nRepeat again ", VXREPEAT},
{"nk Exec rpt k n times", VEXECRPT},
{"n p Set param p ", VSETPARS},
{" Help ", VHELP},
{" Insert find pat", VINSPAT},
{"/",0} /* last variable entry */
};
#endif
oldtty = ttymode;
ttymode = FALSE;
if (!oldtty)
tvclr();
prompt("Parameter : cur val (1=y, 0=n) Prev 16 cmds:");
for (hnum = 0,i = old_cindex ; hnum < 16 ; ++hnum)
{
shocout(old_cmds[i]);
i = ++i % 16;
}
remark("");
prompt("A-Autoindent: "); wtint(autoin);
prompt(" T-TTY mode: "); wtint(ttymode);
prompt(" E-Expand tabs: "); wtint(tabspc); remark("");
prompt("F-Find: ignore case: ");
if (xcases)
tvcout('0');
else
tvcout('1');
prompt(" M-Match wild cards: "); wtint(use_wild); remark("");
prompt("U-User wild card set: "); remark(user_set);
prompt("D disp line:"); wtint(dsplin);
prompt(" S-Scroll window:"); wtint(scroll);
prompt(" V-Virtual window:"); wtint(tvlins);
prompt("/"); wtint(tvhardlines);
prompt(" W-Wrap width:"); wtint(wraplm); remark("");
prompt("O-Output file: "); prompt(dest_file);
prompt(" (input file is: ");prompt(orig_file); remark(")");
remark("");
prompt("Find: |");
for (cp = sbuff ; *cp ; ++cp)
{
shocout(*cp);
}
remark("|");
remark("");
prompt("Max chars: ");
tmp = mxbuff;
#ifdef INT16
if (tmp > 30000) /* handle "neg" size */
{
prompt("30000+");
tmp -= 30000;
}
#endif
wtint(tmp); prompt(" Max lines: "); wtint(mxline);
prompt(" Cur line: "); wtint(curlin);
if (usecz)
prompt(" ^Z for EOF");
remark("");
remark("");
prompt("R-Repeat buffer: ");wtint(rptuse+1);
remark(" All repeat buffers : <contents>:");
for (i = 0 ; i < REPEATBUFS ; ++ i)
{
fields = 5;
shocout('#') ; shocout(i+'1') ; prompt(": <");
for (cp = &rptbuf[i][0] ; *cp ; ++cp)
{
shocout(*cp);
++fields; /* how many letters */
if (*cp < ' ')
++fields;
if (fields >= (tvcols - 6))
{
prompt("+more+");
break;
}
}
remark("");
}
ttymode = oldtty;
memory();
#ifdef FULLHELP
tvxy(1,22);
ask("Press space to exit, anything else for command list ",rp,1);
if (*rp == ' ')
{
ttymode = oldtty;
verify(1);
return;
}
if (!oldtty)
tvclr();
remark("Commands (n => count allowed):");
for (hnum = fields = 0 ; ; ++hnum )
{
prompt(" ");
cp = cmddes[hnum].hmsg;
if (*cp == '/') /* end of variable list */
break;
else
shocout(*cp); /* show n or blank */
msg = ++cp; /* where message is, skipping 'n' field */
while (*cp) /* ship to lex value */
++cp;
i = cmddes[hnum].Vmsg; /* get the lexical index */
shocout(cupper(lexsym[i])); /* show the command */
if (lexsym[i] >= ' ')
shocout(' '); /* skip space for no '^' */
shocout(' '); /* space to separate */
prompt(msg); /* and show the message */
if (++fields == 3) /* bump fields, see if need newline */
{
fields = 0;
remark("");
}
}
remark("");
remark(" n<>$$ Rpt loop @ Invoke cmd file $ Escape");
remark("Wild cards:");
remark("^A-alphanumeric ^D-digit ^L-letter ^O-other,(not-^A) ^P-punctuation");
remark("^X-any character ^U-user set -- ^W-word of ^.. ^N-not in word of ^..");
#endif
if (!oldtty)
tvxy(1,24);
ask("Press any key to resume ",rp,1);
ttymode = oldtty;
verify(1);
#else
tverr(&rptbuf[rptuse][0]);
#endif
}
/* =============================>>> SHOCOUT <<<==